#include <bits/stdc++.h>
using namespace std;
#define NAME 12

typedef struct Node
{
    long long number;
    double score;
    struct Node *next, *pre;
} Linked_List_Node;

typedef struct
{
    Linked_List_Node *head, *end;
    int length;
} Linked_List;

Linked_List_Node *linked_list_node_construct(char name[], int score);
Linked_List *linked_list_consctruct();
void delete_linked_list_node_by_number(Linked_List *linkedList, long long number);
void print_linked_list_nodes(Linked_List *linkedList);
void add_node_by_number(Linked_List *ls, Linked_List_Node *lln, int position);

Linked_List_Node *linked_list_node_construct(long  long number, double score)
{
    Linked_List_Node *tmp = new Linked_List_Node;
    tmp->number = number;
    tmp->score = score;
    tmp->next = NULL;
    tmp->pre = NULL;
    return tmp;
}

Linked_List *linked_list_consctruct()
{
    Linked_List *tmp = new Linked_List;
    Linked_List_Node *head = linked_list_node_construct(-100, 0);
    tmp->head = head;
    tmp->length = 0;
    return tmp;
}

void print_linked_list_nodes(Linked_List *linkedList)
{
    Linked_List_Node *now = linkedList->head;
    while (now != NULL)
    {
        if (now->number == -100)
        {
            now = now->next;
            continue;
        }
        printf ("%lld %5.1lf\n",now->number,now->score);
     //   cout << now->number << " " << now->score << endl;
        now = now ->next;
    }
    // cout << "--------------" << endl;
}

int main()
{
 //   freopen("ls.in","r",stdin);
   // cout<<"debug"<<endl;
    Linked_List *ls = linked_list_consctruct();
    string s;
    do
    {
        cin >> s;
        int l = s.length();
        if (l == 1)
            break;

        int flag;
        for (int i = 0; i < l; i++)
        {
            if (s[i] == ',')
            {
                flag = i;
                break;
            }
        }
        long long number;
        double score;
        static char String[10005];
        for (int i = 0; i < l; i++)
        {
            String[i] = s[i];
        }
        String[l] = '\0';
        sscanf(String, "%lld,%lf", &number, &score);
        Linked_List_Node *neww = linked_list_node_construct(number, score);
        add_node_by_number(ls, neww, ls->length);
    } while (1);
    char String[10005];
    //scanf("%s",String);
    //cout<<String<<endl;
    //print_linked_list_nodes(ls);
    while (scanf("%s",String)!=EOF)
    {   
        int flag = 0; 
        for (int i = 0; i < strlen(String); i++)
        {
            if (String[i] == ',')
                flag = 1;
        }
        if (flag)
        {
            long long number;
            double score;

            sscanf(String, "%lld,%lf", &number, &score);
            Linked_List_Node *neww = linked_list_node_construct(number, score);
            int cnt;
            scanf("%d", &cnt);
         //   cout<<"debug"<<endl;
            add_node_by_number(ls, neww, cnt-1);
          //  print_linked_list_nodes(ls);
         //   break;
        }
        else
        {
            int number;
            sscanf(String, "%lld", &number);
         //   cout<<number<<endl;
            delete_linked_list_node_by_number(ls, number);
           // print_linked_list_nodes(ls);
        }
      //  print_linked_list_nodes(ls);
    
        
    }
    //cout<<"debug"<<endl;
    print_linked_list_nodes(ls);
    return 0;
}

void delete_linked_list_node_by_number(Linked_List *linkedList, long long number)
{
    Linked_List_Node *now = linkedList->head;
    while (now->next != NULL && now->next->number != number)
    {
       // cout<<now->number<<endl;
        now = now->next;
        
    }
    now->next = now->next->next;
    return;
}
void add_node_by_number(Linked_List *ls, Linked_List_Node *Node, int number)
{
    //cout<<number<<endl;
    ls->length++;
    Linked_List_Node *now = ls->head;
    int cnt = 0;
    while (cnt < number)
    {
        cnt++;
        now = now->next;
    }
    Node->next = now->next;
    now->next = Node;
   // cout<<"debug"<<endl;
    return;
}